﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OleDb;
using GrayMatterSoft;


public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string deger = deger = Request.QueryString["sayfa"];
        if (deger == "kasko")
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            Panel3.Visible = false;

        }
        if (deger == "saglik")
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
            Panel3.Visible = false;

        }

        if (deger == "konut")
        {
            Panel1.Visible = false;
            Panel2.Visible = false;
            Panel3.Visible = true;

        }


    }
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        //sqlacs.InsertParameters.Add("tekliftarihi", DateTimeKind.Local.ToString());

    }
    protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {




        TextBox tckimlikno = FormView1.FindControl("tckimliknoTextBox") as TextBox;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from tblmusteri where tckimlikno='" + tckimlikno.Text.ToString() + "'", con);


        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {
            Session.Add("UID", Convert.ToInt32(oku[0].ToString()));

        }
        con.Close();

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }

        DropDownList markasi = FormView1.FindControl("DropDownList1") as DropDownList;
        TextBox modeli = FormView1.FindControl("modeli") as TextBox;
        DropDownList modelyil = FormView1.FindControl("dolduryil") as DropDownList;
        DropDownList ikmil = FormView1.FindControl("DropDownList2") as DropDownList;
        DropDownList plakail = FormView1.FindControl("DropDownList3") as DropDownList;
        RadioButtonList ksekli = FormView1.FindControl("RadioButtonList1") as RadioButtonList;
        TextBox plakano = FormView1.FindControl("plakano") as TextBox;
        RadioButtonList odemetip = FormView1.FindControl("RadioButtonList2") as RadioButtonList;
        DropDownList odemetaksit = FormView1.FindControl("odemetaksit") as DropDownList;

        OleDbCommand uygula = new OleDbCommand("insert into tblkasko(userid,kurum_firma,plakano,aracmarka,aracmodel,modelyil,ikametil,plakail,ksekli,odemetip,odemetaksit) values(?,?,?,?,?,?,?,?,?,?,?)", con);
        uygula.Parameters.Add("userid", System.Data.OleDb.OleDbType.Integer).Value = Session.Contents["UID"].ToString();
        uygula.Parameters.Add("kurum_firma", System.Data.OleDb.OleDbType.Integer).Value = Request.QueryString["ssirket"].ToString();
        uygula.Parameters.Add("plakano", System.Data.OleDb.OleDbType.VarChar).Value = plakano.Text.ToString();
        uygula.Parameters.Add("aracmarka", System.Data.OleDb.OleDbType.VarChar).Value = markasi.Text.ToString();

        uygula.Parameters.Add("aracmodel", System.Data.OleDb.OleDbType.VarChar).Value = modeli.Text.ToString();
        uygula.Parameters.Add("modelyil", System.Data.OleDb.OleDbType.VarChar).Value = modelyil.Text.ToString();
        uygula.Parameters.Add("ikametil", System.Data.OleDb.OleDbType.VarChar).Value = ikmil.Text.ToString();
        uygula.Parameters.Add("plakail", System.Data.OleDb.OleDbType.VarChar).Value = plakail.Text.ToString();
        uygula.Parameters.Add("ksekli", System.Data.OleDb.OleDbType.VarChar).Value = ksekli.Text.ToString();
        uygula.Parameters.Add("odemetip", System.Data.OleDb.OleDbType.VarChar).Value = odemetip.Text.ToString();

        RadioButtonList odemetipi = FormView1.FindControl("RadioButtonList2") as RadioButtonList;

        if (odemetipi.SelectedIndex == 0)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = 0;
        }
        if (odemetipi.SelectedIndex == 1)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = odemetaksit.Text.ToString();
        }



        uygula.ExecuteNonQuery();
        con.Close();
        Response.Redirect("sayfagoster.aspx?sayfa=kasko&MID=" + Session.Contents["UID"]);


    }

    private TypeCode DateTime()
    {
        throw new NotImplementedException();
    }

    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {

    }
    protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {

    }
    protected void FormView1_ItemCreated(object sender, EventArgs e)
    {

    }
    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        //if (e.CommandName == "Insert")
        //{

        //}
    }
    Label labelkurum = new Label();
    protected void FormView1_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {

            DropDownList dolduryil = FormView1.FindControl("dolduryil") as DropDownList;
            dolduryil.Items.Add(" Yıl Seçiniz");



            for (int i = 1997; i < 2009; i++)
            {


                if (i == 1997)
                {
                    dolduryil = FormView1.FindControl("dolduryil") as DropDownList;
                    dolduryil.Items.Add(i.ToString() + " ve öncesi");

                }
                else
                {
                    dolduryil = FormView1.FindControl("dolduryil") as DropDownList;
                    dolduryil.Items.Add(i.ToString());
                }


            }
        }
        
        Label labelkurum = FormView1.FindControl("labelkurum") as Label;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from SSIRKETLERI where SID=" + Request.QueryString["ssirket"].ToString(), con);
        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {

            labelkurum.Text = oku["SISIM"].ToString();

        }
        con.Close();





       

        DropDownList ikmil = FormView1.FindControl("DropDownList2") as DropDownList;
        ikmil.Items.Insert(0, "Lütfen Seçiniz");
        DropDownList plakail = FormView1.FindControl("DropDownList3") as DropDownList;
        plakail.Items.Insert(0, "Lütfen Seçiniz");



    }
    protected void InsertButton_Click1(object sender, EventArgs e)
    {

    }
    protected void FormView2_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        TextBox tckimlikno = FormView2.FindControl("tckimliknoTextBox") as TextBox;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from tblmusteri where tckimlikno='" + tckimlikno.Text.ToString() + "'", con);


        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {
            Session.Add("UID", Convert.ToInt32(oku[0].ToString()));

        }
        con.Close();

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }


        GMDatePicker dogumtarihi = FormView2.FindControl("GMDatePicker1") as GMDatePicker;
        
        TextBox kangrubu = FormView2.FindControl("kangrubu") as TextBox;
        TextBox boy = FormView2.FindControl("boy") as TextBox;
        TextBox kilo = FormView2.FindControl("kilo") as TextBox;

        DropDownList odemetaksiti = FormView2.FindControl("odemetaksit2") as DropDownList;
        RadioButtonList odemetip = FormView2.FindControl("RadioButtonList4") as RadioButtonList;
        OleDbCommand uygula = new OleDbCommand("insert into tblsaglik(userid,kurum_firma,cinsiyet,dogumtarihi,kangrubu,boy,kilo,odemetip,odemetaksit) values(?,?,?,?,?,?,?,?,?)", con);
        uygula.Parameters.Add("userid", System.Data.OleDb.OleDbType.Integer).Value = Session.Contents["UID"].ToString();
        uygula.Parameters.Add("kurum_firma", System.Data.OleDb.OleDbType.Integer).Value = Request.QueryString["ssirket"].ToString();

        RadioButtonList cinsiyeti = FormView2.FindControl("RadioButtonList3") as RadioButtonList;
        if (cinsiyeti.SelectedIndex == 0)
        {
            uygula.Parameters.Add("cinsiyet", System.Data.OleDb.OleDbType.VarChar).Value = cinsiyeti.Text.ToString();
        }
        if (cinsiyeti.SelectedIndex == 1)
        {
            uygula.Parameters.Add("cinsiyet", System.Data.OleDb.OleDbType.VarChar).Value = cinsiyeti.Text.ToString();
        }




        uygula.Parameters.Add("dogumtarihi", System.Data.OleDb.OleDbType.Date).Value = dogumtarihi.Date.ToShortDateString();

        uygula.Parameters.Add("kangrubu", System.Data.OleDb.OleDbType.VarChar).Value = kangrubu.Text.ToString();

        uygula.Parameters.Add("boy", System.Data.OleDb.OleDbType.VarChar).Value = boy.Text.ToString();
        uygula.Parameters.Add("kilo", System.Data.OleDb.OleDbType.VarChar).Value = kilo.Text.ToString();


        //uygula.Parameters.Add("odemetip", System.Data.OleDb.OleDbType.VarChar).Value = "Peşin";
        //uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = 2;
        
        uygula.Parameters.Add("odemetip", System.Data.OleDb.OleDbType.VarChar).Value = odemetip.Text.ToString();


        RadioButtonList odemetipisaglik = FormView2.FindControl("RadioButtonList4") as RadioButtonList;

        if (odemetipisaglik.SelectedIndex == 0)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = 0;
        }
        if (odemetipisaglik.SelectedIndex == 1)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = odemetaksiti.Text.ToString();
        }





        uygula.ExecuteNonQuery();
        con.Close();
        Response.Redirect("sayfagoster.aspx?sayfa=saglik&MID=" + Session.Contents["UID"]);
    }
    protected void FormView2_Load(object sender, EventArgs e)
    {

        Label labelkurum = FormView2.FindControl("labelkurum") as Label;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from SSIRKETLERI where SID=" + Request.QueryString["ssirket"].ToString(), con);
        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {

            labelkurum.Text = oku["SISIM"].ToString();

        }
        con.Close();
    }
    protected void FormView3_Load(object sender, EventArgs e)
    {
        Label labelkurum = FormView3.FindControl("labelkurum") as Label;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from SSIRKETLERI where SID=" + Request.QueryString["ssirket"].ToString(), con);
        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {

            labelkurum.Text = oku["SISIM"].ToString();

        }
        con.Close();
    }
    protected void FormView3_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        TextBox tckimlikno = FormView3.FindControl("tckimliknoTextBox") as TextBox;
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["acsbagla"].ConnectionString);
        OleDbCommand komutsec = new OleDbCommand("select * from tblmusteri where tckimlikno='" + tckimlikno.Text.ToString() + "'", con);


        if (con.State == ConnectionState.Closed)
            con.Open();
        OleDbDataReader oku = komutsec.ExecuteReader();


        while (oku.Read())
        {
            Session.Add("UID", Convert.ToInt32(oku[0].ToString()));

        }
        con.Close();

        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }

      
        TextBox konutilce = FormView3.FindControl("konutilce") as TextBox;
        TextBox konuttipi = FormView3.FindControl("konuttipi") as TextBox;
        TextBox konutyapi = FormView3.FindControl("konutyapi") as TextBox;
        TextBox konutkull = FormView3.FindControl("konutkull") as TextBox;
        DropDownList konutill = FormView3.FindControl("DropDownListil") as DropDownList;
        DropDownList odemetaksit = FormView3.FindControl("odemetaksit3") as DropDownList;
        RadioButtonList odemetip = FormView3.FindControl("RadioButtonList5") as RadioButtonList;
        OleDbCommand uygula = new OleDbCommand("insert into tblkonut(userid,kurum_firma,konutil,konutilce,konuttipi,konutyapi,konutkull,odemetip,odemetaksit) values(?,?,?,?,?,?,?,?,?)", con);
        uygula.Parameters.Add("userid", System.Data.OleDb.OleDbType.Integer).Value = Session.Contents["UID"].ToString();
        uygula.Parameters.Add("kurum_firma", System.Data.OleDb.OleDbType.Integer).Value = Request.QueryString["ssirket"].ToString();
        uygula.Parameters.Add("konutil", System.Data.OleDb.OleDbType.VarChar).Value = konutill.Text.ToString();
        uygula.Parameters.Add("konutilce", System.Data.OleDb.OleDbType.VarChar).Value = konutilce.Text.ToString();

        uygula.Parameters.Add("konuttipi", System.Data.OleDb.OleDbType.VarChar).Value = konuttipi.Text.ToString();

        uygula.Parameters.Add("konutyapi", System.Data.OleDb.OleDbType.VarChar).Value = konutyapi.Text.ToString();
        uygula.Parameters.Add("konutkull", System.Data.OleDb.OleDbType.VarChar).Value = konutkull.Text.ToString();

        uygula.Parameters.Add("odemetip", System.Data.OleDb.OleDbType.VarChar).Value = odemetip.Text.ToString();


        RadioButtonList odemetipi = FormView3.FindControl("RadioButtonList5") as RadioButtonList;

        if (odemetipi.SelectedIndex == 0)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = 0;
        }
        if (odemetipi.SelectedIndex == 1)
        {
            uygula.Parameters.Add("odemetaksit", System.Data.OleDb.OleDbType.Integer).Value = odemetaksit.Text.ToString();
        }



        uygula.ExecuteNonQuery();
        con.Close();
        Response.Redirect("sayfagoster.aspx?sayfa=konut&MID=" + Session.Contents["UID"]);
    }



    protected void RadioButton5_CheckedChanged(object sender, EventArgs e)
    {



    }
    protected void RadioButton4_CheckedChanged(object sender, EventArgs e)
    {


    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void RadioButtonList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        RadioButtonList odemetipi = FormView1.FindControl("RadioButtonList2") as RadioButtonList;

        if (odemetipi.SelectedIndex == 0)
        {
            DropDownList odemetaksit = FormView1.FindControl("odemetaksit") as DropDownList;
            odemetaksit.Visible = false;
        }
        if (odemetipi.SelectedIndex == 1)
        {
            DropDownList odemetaksit = FormView1.FindControl("odemetaksit") as DropDownList;
            odemetaksit.Items.Clear();

            for (int i = 1; i < 25; i++)
            {
                odemetaksit.Items.Add(i.ToString());
            }

            odemetaksit.Visible = true;
        }


    }

    protected void odemetipii_SelectedIndexChanged(object sender, EventArgs e)
    {

        //RadioButtonList odemetipi = FormView2.FindControl("odemetipii") as RadioButtonList;

        //if (odemetipi.SelectedIndex == 0)
        //{
        //    DropDownList odemetaksit = FormView2.FindControl("odemetaksit2") as DropDownList;
        //    odemetaksit.Visible = false;
        //}
        //if (odemetipi.SelectedIndex == 1)
        //{
        //    DropDownList odemetaksit = FormView2.FindControl("odemetaksit2") as DropDownList;
        //    odemetaksit.Items.Clear();

        //    for (int i = 1; i < 25; i++)
        //    {
        //        odemetaksit.Items.Add(i.ToString());
        //    }

        //    odemetaksit.Visible = true;
        //}



    }
    protected void odemetaksit2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void RadioButtonList4_SelectedIndexChanged(object sender, EventArgs e)
    {
        RadioButtonList odemetipsaglik = FormView2.FindControl("RadioButtonList4") as RadioButtonList;

        if (odemetipsaglik.SelectedIndex == 0)
        {
            DropDownList odemetaksitsaglik = FormView2.FindControl("odemetaksit2") as DropDownList;
            odemetaksitsaglik.Visible = false;
        }
        if (odemetipsaglik.SelectedIndex == 1)
        {
            DropDownList odemetaksitsaglik = FormView2.FindControl("odemetaksit2") as DropDownList;
            odemetaksitsaglik.Items.Clear();

            for (int i = 1; i < 25; i++)
            {
                odemetaksitsaglik.Items.Add(i.ToString());
            }

            odemetaksitsaglik.Visible = true;

        }
    }
    protected void odemetaksit3_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void RadioButtonList5_SelectedIndexChanged(object sender, EventArgs e)
    {

        RadioButtonList odemetipkonut = FormView3.FindControl("RadioButtonList5") as RadioButtonList;

        if (odemetipkonut.SelectedIndex == 0)
        {
            DropDownList odemetaksitkonut = FormView3.FindControl("odemetaksit3") as DropDownList;
            odemetaksitkonut.Visible = false;
        }
        if (odemetipkonut.SelectedIndex == 1)
        {
            DropDownList odemetaksitkonut = FormView3.FindControl("odemetaksit3") as DropDownList;
            odemetaksitkonut.Items.Clear();

            for (int i = 1; i < 25; i++)
            {
                odemetaksitkonut.Items.Add(i.ToString());
            }

            odemetaksitkonut.Visible = true;

        }

    }
    protected void dogumtarihi_TextChanged(object sender, EventArgs e)
    {
       
    }
    protected void dogumtarihi_Init(object sender, EventArgs e)
    {
    
    }
    protected void dogumtarihi_Load(object sender, EventArgs e)
    {
        


       
    }
    protected void dogumtarihi_PreRender(object sender, EventArgs e)
    {
       
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        
    }
}
